package com.nf.controller;

import com.nf.entity.Jdbc;
import com.nf.service.JdbcServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/insert")
public class JdbcInsertServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        int id=Integer.parseInt(req.getParameter("id"));
        String name=req.getParameter("name");
        Jdbc jdbc=new Jdbc();
        jdbc.setId(id);
        jdbc.setName(name);
        JdbcServiceImpl jdbcService=new JdbcServiceImpl();
        jdbcService.insert(jdbc);
        resp.sendRedirect("/list");
    }
}
